
#include <stdio.h>
#include <stdlib.h>

// #define _CLOG_USE_GLOBAL_FP
// #define _CLOG_USE_LOCAL_FP
#include "clog.h"

FILE *g_clog_fp = NULL;
int g_clog_level = CLOG_LEVEL_INFO;

int main(int argc, char *argv[])
{
	clog_println("%s","before clog_error");
	clog_error("%s", "hello clog_error!\n");
	clog_println("%s","after clog_error");

	clog_warn("%s", "hello clog_warn!\n");
	clog_info("%s", "hello clog_info!\n");
	clog_debug("%s", "hello clog_debug!\n");

	clog_print("%s","hello clog_print!\n");
	clog_println("%s","hello clog_println!");

	clog_open("xxx.log","a+"); // 使用接口打开

	// test log file
	clog_set_level(CLOG_LEVEL_DEBUG);
	clog_errorf("%s", "hello clog_errorf!\n");
	clog_warnf("%s", "hello clog_warnf!\n");
	clog_infof("%s", "hello clog_infof!\n");
	clog_debugf("%s", "hello clog_debugf!\n");

	// module log api
	const const char *MODULE = "MAIN";
	clog_merror(MODULE,"%s", "hello clog_merror!\n");
	clog_mwarn(MODULE,"%s", "hello clog_mwarn!\n");
	clog_minfo(MODULE,"%s", "hello clog_minfo!\n");
	clog_mdebug(MODULE,"%s", "hello clog_mdebug!\n");

	clog_merrorf(MODULE,"%s", "hello clog_merrorf!\n");
	clog_mwarnf(MODULE,"%s", "hello clog_mwarnf!\n");
	clog_minfof(MODULE,"%s", "hello clog_minfof!\n");
	clog_mdebugf(MODULE,"%s", "hello clog_mdebugf!\n");

	clog_close();
	return 0;
}
